package com.enjia.common.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.enjia.enjiashop.MyApplication;

import java.util.List;

/**
 * Created by 张海洋 on 2017-08-29.
 */

public class WechatUtils {

    /**
     * 判断设备是否安装微信APP
     *
     * @return boolean
     */
    public static boolean isWeixinAvilible() {
        final PackageManager packageManager = MyApplication.context.getPackageManager();// 获取packagemanager
        List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// 获取所有已安装程序的包信息
        if (pinfo != null) {
            for (int i = 0; i < pinfo.size(); i++) {
                String pn = pinfo.get(i).packageName;
                if (pn.equals("com.tencent.mm")) {
                    return true;
                }
            }
        }
        ToastUtil.showMessage(MyApplication.context, "请安装微信客户端");
        return false;
    }
}
